
const SM4 = require('gm-crypt').sm4
let key = "BAFCB253BFF3173F"

// 加密
export const encrypt = (word) => {
  const sm4Config = {
    key,
    mode: 'ecb',
    cipherType: 'base64'
  }
  const sm4 = new SM4(sm4Config)
  const ecryptedStr = sm4.encrypt(word)
  return ecryptedStr
}

// 解密
export const decrypt = (word) => {
  const sm4Config = {
    key,
    mode: 'ecb',
    cipherType: 'base64'
  }
  const sm4 = new SM4(sm4Config)
  const decryptedStr = sm4.decrypt(word)
  return decryptedStr
}
